home *** CD-ROM | disk | FTP | other *** search
Prolog Source | 1986-10-07 | 859 b | 34 lines |
- /* Program 43 */
- /*
- Read 'The Turbo Prolog File System' in chapter
- 9 . This example is on page 102.
- */
-
- domains
- file = myfile
-
- predicates
- start
- readin(char)
-
- goal
- start.
-
- clauses
- start:-
- write("This program reads input\nfrom the keyboard and\nwrites it to TRYFILE.ONE.\n"),
- write("Press # when done entering:\n"),
- openwrite(myfile,"tryfile.one"),
- readchar(X),
- readin(X),
- closefile(myfile),
- writedevice(screen),
- write("Your input has been transferred to a file").
- readin( '#' ):-!.
- readin('\13'):-!,writedevice(myfile),
- write("\13\10"),writedevice(screen),
- write("\13\10"),readchar(X),readin(X).
- readin( X ):- writedevice(myfile),
- write(X),writedevice(screen),
- write(X),readchar(Y),readin(Y).
-